home *** CD-ROM | disk | FTP | other *** search
-
- #include <windows.h>
- #include "bogus.h"
- #include "wintest.h"
-
- HANDLE hPgmInstance ;
-
- #define IDM_BOGUSEVENT 0x3000
-
-
- void CenterWindow(HWND hWnd)
- {
- int xSize, ySize, xPos, yPos ;
- RECT rc ;
-
- xSize = GetSystemMetrics(SM_CXSCREEN) ;
- ySize = GetSystemMetrics(SM_CYSCREEN) ;
- GetWindowRect(hWnd, &rc) ;
- xPos = (xSize - (rc.right - rc.left)) / 2 ;
- yPos = (ySize - (rc.bottom - rc.top)) / 2 ;
- SetWindowPos(hWnd, NULL, xPos, yPos, 0, 0,
- SWP_DRAWFRAME | SWP_NOSIZE | SWP_NOZORDER) ;
- }
-
-
- LRESULT _loadds FAR PASCAL MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
- LPARAM lParam)
- {
- static WORD wCountTotal = 0;
- WORD wCount ;
-
- lParam = lParam ;
-
- switch (msg)
- {
- case WM_INITDIALOG:
- RemoveMenu(GetSystemMenu(hwndDlg,0),SC_CLOSE,MF_BYCOMMAND) ;
- BogusStart(hwndDlg, IDM_BOGUSEVENT) ;
- break ;
-
- case WM_SHOWWINDOW:
- if (wParam)
- CenterWindow(hwndDlg) ;
- break ;
-
- case WM_COMMAND:
- switch(wParam)
- {
- case IDM_BOGUSEVENT:
- wCount = BogusGetEvent() ;
- while (wCount)
- {
- wCountTotal += wCount ;
- wCount = BogusGetEvent() ;
- }
- SetDlgItemInt(hwndDlg, IDM_COUNT, wCountTotal, FALSE) ;
- break ;
-
- case IDCANCEL:
- EndDialog(hwndDlg, 0) ;
- break ;
- }
- break ;
-
- default:
- return FALSE ;
- }
-
- return TRUE ;
- }
-
-
-
- int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int
- nCmdShow)
- {
- hPgmInstance = hInstance ;
- hPrevInstance = hPrevInstance ;
- lpCmdLine = lpCmdLine ;
- nCmdShow = nCmdShow ;
-
- if (!hPrevInstance)
- {
- if (BogusCheck())
- {
- if (MessageBox(0, "Press OK to begin bogus I/O", "WinTest",
- MB_OKCANCEL|MB_APPLMODAL) == IDOK)
- {
- DialogBox(hPgmInstance, "MainDlg", 0, (FARPROC) MainDlgProc) ;
- BogusStop() ;
- }
- }
- else
- MessageBox(0, "Bogus device not found", "WinTest",
- MB_ICONHAND|MB_OK|MB_APPLMODAL) ;
- }
- else
- MessageBox(0, "Another instance already running", "WinTest",
- MB_ICONEXCLAMATION|MB_OK|MB_APPLMODAL) ;
-
- return 0 ;
- }
-